package org.itboys.core.controller.front;

import com.aliyuncs.exceptions.ClientException;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.itboys.core.service.mongo.front.SundayValidateCodeService;
import org.itboys.core.util.ResponseMessage;
import org.itboys.framework.spring.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 作者：zzq
 * 时间：2017/9/4
 * 描述：验证码
 */
@Controller
@RequestMapping("/sunday/mobile/code")
@Api(value = "code",description = "验证码")
public class SundayFrontValiDateCodeController extends BaseController{
    @Autowired
    private SundayValidateCodeService codeService;
    /**
     * 发送验证码
     * @param request
     * @param response
     * @param mobile
     * @throws ClientException
     */
    @RequestMapping(value = "/send", method = {RequestMethod.POST})
    @ApiOperation(value = "发送验证码")
    public void send(
            HttpServletRequest request,
            HttpServletResponse response,
            @ApiParam(value = "手机号", required = true) @RequestParam(value = "mobile") String mobile
    ) throws ClientException {
        ResponseMessage.success(codeService.sendValidateCode(mobile));
    }
}
